﻿using System;
using System.ComponentModel.Design;
using Microsoft.WowAddonStudio.FrameXml.Components.Descriptors;
using Microsoft.WowAddonStudio.FrameXml.Serialization;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Editors
{
    public class AnchorCollectionEditor : ArrayEditor
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AnchorCollectionEditor"/> class.
        /// </summary>
        /// <param name="type">The data type of the items in the array.</param>
        public AnchorCollectionEditor(Type type)
            : base(type)
        {
            
        }

        /// <summary>
        /// Gets the items in the array.
        /// </summary>
        /// <param name="editValue">The array from which to retrieve the items.</param>
        /// <returns>
        /// An array consisting of the items within the specified array. If the object specified in the <paramref name="editValue"/> parameter is not an array, a new empty object is returned.
        /// </returns>
        protected override object[] GetItems(object editValue)
        {
            var items = base.GetItems(editValue);

            foreach (Anchor item in items)
                FrameXmlTypeDescriptionProviderExtender.Extend(item);
            
            return items;
        }
    }
}
